home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / bbbbs85.lha / rexxDoors / Grin_du_Jour.rexx next >
OS/2 REXX Batch file  |  1994-01-28  |  1KB  |  57 lines

  1. /* $VER: Grin_du_Jour.rexx 6.3 (28.8.93)
  2.     copyright 1991 Richard Lee Stockton
  3.           FREELY DISTRIBUTABLE
  4.  
  5. This will manage grin (cookie, fortune, etc.) files up to about 12 MEG
  6.  
  7. */
  8.  
  9. FF='0C'x  /* FormFeed */
  10. CR='0D'x  /* Carraige Return */
  11. SIGNAL ON BREAK_C
  12. SIGNAL ON BREAK_E
  13.  
  14. ARG name .
  15.  
  16. bbspath=GETCLIP('BBS_path')
  17. filename=bbspath'rexxDoors/Data/Grins' /* Formfeed separated text */
  18. size=WORD(STATEF(filename),2)
  19. fragment=size/3000
  20.  
  21. x=OPEN(f,'RAM:DUMMY','W')                /* write to a dummy file */
  22. IF x=0 THEN EXIT(20);
  23. CALL WRITELN(f,'dummy')
  24. CALL CLOSE(f)
  25. micros=WORD(STATEF('RAM:DUMMY'),7)        /*  0 >= micros < 3000  */
  26. location=fragment*micros
  27. IF fragment>1000 THEN
  28.   location=location+fragment*RIGHT(DATE('I'),2)/100
  29. ELSE IF fragment>100 THEN
  30.   location=location+fragment*RIGHT(DATE('I'),1)/10
  31. location=TRUNC(location)
  32. IF location>size THEN location=micros
  33.  
  34. x=OPEN(f,filename,'R')
  35. IF x=0 THEN RETURN(10);
  36. CALL SEEK(f,location,'B')            /* point to the random place */
  37. line=''
  38. DO WHILE line~=FF & ~EOF(f)        /* find the start (a formfeed) */
  39.   line=READLN(f)
  40. END
  41. count=0
  42. line=''
  43. IF ~EOF(f) THEN      /* if EOF then must be right at end. missed! */
  44.   DO WHILE line~=FF & ~EOF(f)         /* otherwise, show the page */
  45.     line=READLN(f)
  46.     IF ~EOF(f) & line~=FF THEN
  47.       DO
  48.         SAY line||CR
  49.         count=count+1
  50.       END
  51.   END
  52. BREAK_C:
  53. BREAK_E:
  54. CALL CLOSE(f)
  55. RETURN(count);
  56. EXIT;                           /* a little redundant, so sue me! */
  57.